mui.init({
	swipeBack:false,//右滑关闭功能
});
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready',plusReady,false);
}
var biz,bizname;
function plusReady(){
	var current=plus.webview.currentWebview();
	biz = current.biz;
    bizname = current.bizname;
	$("#zclist_title").text(bizname+"已办");
	loadListData();
	
	//返回首页
	document.getElementById('home').addEventListener('tap', function() {
	    var h=plus.webview.getWebviewById('mainpage');
	    plus.webview.show(h);
	    mui.fire(h,'tabClick',{tabId:'defaultTab'});
	});
	
	document.addEventListener("loadListData",loadListData);
}
//加载自身页面信息
function loadListData() {
	
	var token = plus.storage.getItem("token");
	if(token==null||token==""){
		return;
	}else{
	   panUtil.ajaxLoding.start();
	   mui.ajax(baseServerAdrr+'/zc/getSPLB',{
	   data: {
	   		token:token,
	   		ywlx:biz,
	   		splx:'approved'
	   },
	   dataType:'json',//服务器返回json格式数据
	   type:'post',//HTTP请求类型
	   timeout:30000,//超时时间设置为10秒；
	   success:function(data){
		   panUtil.ajaxLoding.stop();
		   if(data.code=='success'){
		   	  initlist(data.message);
		   }else{
		   	    mui.toast(data.message);
		   	    setTimeout(function(){
		   	    	panUtil.ReLogin();
		   	    },1000);
		   }
	    },
	    error:function(xhr,type,errorThrown){
		   //异常处理；
		   panUtil.ajaxLoding.stop();
		   mui.toast('服务器异常登录失败! zcsplbyb.js');
	    }
		});
	}
}


function detailclick(spbh,biz){
	var listview = mui.openWindow({
		url: "zcspdetail.html",
		id: "zcspdetail",
		extras: {
			bizType : biz,
			bizNo  : spbh,
			bizName  : bizname,
			splx:"ysp"
		},
		createNew: false,
		waiting: {
			autoShow: false
		}
	});
}
//重写返回事件
var old_back = mui.back;
mui.back = function(){
   var h=plus.webview.getWebviewById("zchasDoTab.html");
   mui.fire(h,"loadHasdoData");
   //继续当前页面原有返回逻辑
   old_back();
}
function initlist(datas){
	$("#zclistul").html();
	var datastr="";
	for (var i=0;i<datas.length;i++) {
		var data=datas[i];
		datastr+='<li class="mui-table-view-cell mui-checkbox">';
		datastr+='<div class="mui-table">';
		datastr+='<div class="mui-table-cell mui-col-xs-11"><span style="font-size:15px">申请单位:'+data.SPBDEPT
		           +'&nbsp;&nbsp;<span style="font-size:14px">资产数量:'+data.AMOUNT+'&nbsp;&nbsp; 资产原值:'+data.ZCYZ+'</span></span></div>';
		datastr+='<a class="mui-navigate-right zcliststyle"  href="javascript:void(0)" onclick="detailclick(\'' + data.SPBBH + '\',\'' + biz + '\');">';
		datastr+='<div style="height:20px;margin:0px;"></div>';
		datastr+='</a></div></li>';
	}
	$("#zclistul").html(datastr);
}
